home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / ubmalm.zip / rho.ub < prev    next >
Text File  |  1990-08-22  |  704b  |  18 lines

  1.  1100   *Rho(N,C,Ubnd,&F,&G)
  2.  1110   ' Pollard rho method of factoring n, as modified by Brent.
  3.  1120   ' Modeled on the Pascal version.
  4.  1130   ' 15 May 1990
  5.  1140   local Cc=20,Front,Rear=2,Prod=1,T,I,Count=0,Index=1
  6.  1150   if N<0 then F=0:G=0:return endif
  7.  1160   Front=C+4
  8.  1170   while Count<=Ubnd
  9.  1180   for I=0 to Index
  10.  1190   Front=(Front*Front+C)@N:Prod=((Rear-Front)*Prod)@N
  11.  1200   inc Count:if Count@Cc=0 then T=gcd(N,Prod)
  12.  1210   :if T>1 then F=T:G=N\F:cancel for:return endif endif
  13.  1220   next I
  14.  1230   Rear=Front:Index=2*Index
  15.  1240   for I=1 to Index:Front=(Front*Front+C)@N:next I
  16.  1250   wend ' If here, failure.
  17.  1260   F=-1:G=-1:return ' End of subroutine Rho.
  18.